package co.edu.usbcali.raju.model;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import co.edu.usbcali.raju.games.chess.model.ChessBoard;

public class ComplexEvaluator implements IEvaluator {
	
	Map<IEvaluator, Double> evaluators=new HashMap<IEvaluator, Double>();

	@Override
	public double evaluate(Board board, String player) {
		Set<IEvaluator> keys=evaluators.keySet();
		double ret=0;
		for (IEvaluator iEvaluator : keys) {
			ret+=iEvaluator.evaluate(board, player)*evaluators.get(iEvaluator);
		}	
		if(player.equals(ChessBoard.BLACK)){
			ret*=-1;
		}
		return ret;
	}
	
	public void put(IEvaluator evaluator,Double weight){
		evaluators.put(evaluator, weight);
	}
	
	public Double remove(IEvaluator evaluator){
		return evaluators.remove(evaluator);
	}

}
